In [1]:
import pandas as pd
import plotly.express as px
In [2]:
df = pd.read_csv(r"D:\Development\vs.code\Data Science\data Analaytis\study problems\datasets\linkedin-reviews.csv")
In [3]:
df.head(5)
Out[3]:
Review Rating
0 Does absolutely nothing for a LinkedIn beginne... 1
1 Force close(galaxy tab) 1
2 Slow and it tries to upload your contacts with... 1
3 Add ability to customize the profile and move ... 4
4 Good app, but it's a pain that it's not possib... 4
In [4]:
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 702 entries, 0 to 701
Data columns (total 2 columns):
 #   Column  Non-Null Count  Dtype 
---  ------  --------------  ----- 
 0   Review  702 non-null    object
 1   Rating  702 non-null    int64 
dtypes: int64(1), object(1)
memory usage: 11.1+ KB
In [5]:
import plotly.io as pio
pio.templates.default = "plotly_white"
fig = px.histogram(df,x = 'Rating')
fig.update_layout(title = "Total number of Rating", xaxis_title = "Rating",yaxis_title = "Count",bargap=0.3)
fig.show()
In [6]:
df['length_review'] = df["Review"].apply(len)
In [7]:
fig = px.histogram(df,x = 'length_review',color_discrete_sequence = ["green"],opacity = 0.7)
fig.update_layout(title="length of review",xaxis_title = "review", yaxis_title="count",bargap = 0.3)
fig.show()
In [8]:
from textblob import TextBlob
def Text_blob_review(review):
    sentiment = TextBlob(review).sentiment
    if sentiment.polarity > 0.1:
        return 'positive'
    elif sentiment.polarity < 0.1:
        return 'negative'
    else:
        return 'natural'
    
df["sentiment"] = df["Review"].apply(Text_blob_review)
df
Out[8]:
Review Rating length_review sentiment
0 Does absolutely nothing for a LinkedIn beginne... 1 80 negative
1 Force close(galaxy tab) 1 23 negative
2 Slow and it tries to upload your contacts with... 1 61 negative
3 Add ability to customize the profile and move ... 4 90 negative
4 Good app, but it's a pain that it's not possib... 4 133 positive
... ... ... ... ...
697 Can't trust, Going to uninstall just for that ... 1 53 negative
698 It really gets me linked in with my friends. H... 5 72 positive
699 It lacks most of what makes the other social n... 4 81 positive
700 Really disappointed in the new version. Seems ... 2 123 negative
701 One of the best looking and well designed apps... 5 80 positive

702 rows × 4 columns

In [9]:
fig = px.histogram(df,x = 'sentiment',color='sentiment',opacity = 0.8)
fig.update_layout(title = "distribution of sentiments",xaxis_title = "sentiment review", yaxis_title = "count")
fig.show()
In [10]:
fig = px.histogram(df,x = 'Rating',color='sentiment',opacity = 0.8,barmode = "group")
fig.update_layout(title = "distribution of sentiments",xaxis_title = "sentiment review", yaxis_title = "count")
fig.show()
In [17]:
from wordcloud import WordCloud

def word_cloud_sentiment(sentiment):
    text = ' '.join(review for review in df[df['sentiment']==sentiment]['Review'])
    word_cloud = WordCloud(width = 800,height = 400,background_color = 'white').generate(text)
    fig = px.imshow(word_cloud,title = f'word cloud for {sentiment} review')
    fig.update_xaxes(visible=False)
    fig.update_yaxes(visible=False)
    fig.show()



for sentiment in ['positive','negative','natural']:
    word_cloud_sentiment(sentiment)
In [ ]:
 
In [ ]: